home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / DRIVES.SWG / 0083_Valid Drives.pas < prev    next >
Pascal/Delphi Source File  |  1994-08-25  |  1KB  |  56 lines

  1.  
  2. program valid_drv;
  3.  
  4. uses dos;
  5.  
  6. Function ready_drives reports as valid only drives that are 
  7. ready to be read. Findfirst does not cause a critical error even 
  8. if a floppy is not ready and in machines with a single floppy 
  9. the prompt to insert a diskette when testing for the B: drive 
  10. (from IO.SYS) is avoided by the use of DOS services $4408 and 
  11. $440E (requires DOS 3.2 or up). - 
  12. Jose Campione (1:163/513.3) August 1994 -
  13.  
  14. function ready_drives: string;
  15. var
  16.   regs : registers;
  17.   i : byte;
  18.   drs: string;
  19.   sr : searchrec;
  20.  
  21.   function is_last(d:byte):boolean;
  22.   {true if d is the only or the last name assigned to that drive}
  23.   begin
  24.     regs.ax:= $440E;
  25.     regs.bl:= d;
  26.     msdos(regs);
  27.     is_last:= ((regs.flags and fcarry) = 0) and ((regs.al = 0) or (regs.al = d));
  28.   end;
  29.  
  30.   function is_floppy(d: byte): boolean;
  31.   {true if d is a removable medium}
  32.   begin
  33.     regs.ax:= $4408;
  34.     regs.bl:= d;
  35.     msdos(regs);
  36.     is_floppy := ((regs.flags and fcarry) = 0) and (regs.ax = 0);
  37.   end;
  38.  
  39. begin
  40.   drs:= '';
  41.   for i:= 1 to 26 do begin
  42.     if (not is_floppy(i)) or is_last(i) then begin
  43.       findfirst(chr(i + 64) + ':\*.*',AnyFile,sr);
  44.       if doserror = 0 then drs:= drs + chr(i + 64);
  45.     end;
  46.   end;
  47.   ready_drives:= drs;
  48. end;
  49.  
  50. begin
  51.   writeln('drives ready : ',ready_drives);
  52. end.
  53.  
  54.